<template>
  <div class="home">
    <el-container style="height: 100vh; border: 1px solid #eee">
      <el-aside width="200px" style="background-color: rgb(238, 241, 246);position:relative">
        <el-menu router class="el-menu-vertical-demo" :collapse="isCollapse">
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-message"></i>分类
            </template>
            <el-menu-item index="/home/category">分类列表</el-menu-item>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-message"></i>视频
            </template>
            <el-menu-item index="/home/video">视频列表</el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-message"></i>文章
            </template>
            <el-menu-item index="/home/article">文章列表</el-menu-item>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-message"></i>广告
            </template>
            <el-menu-item index="/home/advert">广告列表</el-menu-item>
          </el-submenu>
          <el-submenu index="5">
            <template slot="title">
              <i class="el-icon-message"></i>账号
            </template>
            <el-menu-item index="/home/account">账号列表</el-menu-item>
          </el-submenu>
        </el-menu>
        <el-radio-group v-model="isCollapse" class="open-close">
          <el-radio-button :label="false" style="width:100%" @click="handleOpen">展开</el-radio-button>
          <el-radio-button :label="true" style="width:100%" @click="handleClose">收起</el-radio-button>
        </el-radio-group>
      </el-aside>
      <el-container>
        <el-header style="text-align: right; font-size: 12px">
          <el-dropdown>
            <i class="el-icon-setting" style="margin-right: 15px"></i>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="logOut">退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <span>{{$store.state.username}}</span>
        </el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isCollapse: false
    }
  },
  methods: {
    logOut() { //退出登录
      localStorage.clear()
      this.$store.commit('initState')
      this.$router.push({
        name: 'Login'
      })
    },
    handleOpen() { //侧边栏展开
      this.isCollapse = true
    },
    handleClose() { //侧边栏收起
      this.isCollapse = false
      console.log($('el-aside'))
    }
  },
};
</script>
<style>
.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
}
.el-aside {
  color: #333;
}
/* .el-aside:not(.el-menu--collapse) {
  width: 200px !important;
} */
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
}
.open-close {
  width: 100%;
  position: absolute;
  bottom: 0;
  left: 0;
  border-right: 1px solid #e6e6e6;
  box-sizing: border-box;
}
.el-radio-button__inner {
  width: 100%;
  border: none;
  box-sizing: border-box;
}
</style>